package com.example.wishstar.api;

import androidx.room.Delete;

import com.example.wishstar.model.HabitWish;
import com.example.wishstar.model.Memory;
import com.example.wishstar.model.OldHabitWish;
import com.example.wishstar.model.Star;
import com.example.wishstar.model.Users;
import com.example.wishstar.utils.ApiResponse;

import java.util.List;

import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.PUT;
import retrofit2.http.Path;

public interface Api
{
    /**
     * 登陆
     * @param body
     * @return
     */
    @POST("users/login")
    Call<ApiResponse<Integer>> login(
            @Body RequestBody body
    );

    @POST("users/register")
    Call<ApiResponse<Integer>> register(
            @Body RequestBody body
    );

    @GET("users/getCheckCode")
    Call<ApiResponse<String>> getCode(
            @Query("state") int state,
            @Query("userMail") String userMail
    );

    @PUT("users/updatePwd")
    Call<ApiResponse<String>> reset(
            @Body RequestBody body
    );

    @GET("users/getUserInfo/{userId}")
    Call<ApiResponse<Users>> getUsers(
            @Path("userId") Integer userId
    );

    @PUT("users/updateUserMsg")
    Call<ApiResponse<String>> updateUserMsg(
            @Body RequestBody body
    );

    @GET("wish/getAllFinishedWish")
    Call<ApiResponse<List<Star>>> getStars();

    @PUT("wish/likeOneWish/{wishId}")
    Call<ApiResponse<Integer>> likeOneWish(
            @Path("wishId") Integer wishId
    );

    @GET("memory/getAll/{userId}")
    Call<ApiResponse<List<Memory>>> getMemorys(
            @Path("userId") Integer userId
    );

    @GET("habit/getMyhabitAndWish/{userId}")
    Call<ApiResponse<HabitWish>> getHabitWish(
            @Path("userId") Integer userId
    );

    /**
     * 我的页/查找某用户的已归档的习惯和已完成的愿望
     * @param userId
     * @return 在归档的情况下，savedHabitList中dayNum表示坚持习惯打卡的天数，gmtModified表示习惯归档时间，gmtCreate表示习惯开始时间，可以在前端显示一段时间区间。
     * savedWishList中的。finishTime表示愿望完成打卡的日期，类型为LocalDate；favourNum表示该愿望在许愿星中被点赞的数量。
     */
    @GET("habit/getMySavedHabit/{userId}")
    Call<ApiResponse<OldHabitWish>> getOldHabitWish(
            @Path("userId") Integer userId
    );

    @POST("memory/create")
    Call<ApiResponse<Integer>> addMemory(
            @Body RequestBody body
    );

    @POST("habit/create")
    Call<ApiResponse<Integer>> addHabit(
            @Body RequestBody body
    );

    @POST("wish/create")
    Call<ApiResponse<Integer>> addWish(
            @Body RequestBody body
    );

    @PUT("habit/update")
    Call<ApiResponse<Integer>> updateHabit(
            @Body RequestBody body
    );

    @PUT("wish/finishWish")
    Call<ApiResponse<Integer>> updateWish(
            @Body RequestBody body
    );

    @PUT("wish/delay")
    Call<ApiResponse<Integer>> delayWish(
            @Body RequestBody body
    );

    @DELETE("memory/delete/{memoryId}")
    Call<ApiResponse<String>> deleteMemory(
            @Path("memoryId") Integer memoryId
    );

    @DELETE("wish/delete/{wishId}")
    Call<ApiResponse<String>> deleteWish(
            @Path("wishId") Integer wishId
    );
    @DELETE("habit/delete/{habitId}")
    Call<ApiResponse<String>> deleteHabit(
            @Path("habitId") Integer habitId
    );
}
